#ifndef __MAPS_H__
#define __MAPS_H__
#include "error.h"
#include <stdio.h>
#include <stdlib.h>
#include <sstream>
#include "types.h"

class Multimap {
private:
	typedef std::vector<uint> 	uintl_t;
	typedef std::vector<uintl_t> uintf_t;
	uintf_t	_aMap;
	uint		_iMaxX;
	uint		_iMaxY;
	bool		_bModified;
	uint		_iMax;
	uint 		_iMin;
protected:
	bool validXY(const uint x,const uint y) const;
	bool validX(const uint x) const;
	bool validY(const uint y) const;
	bool valid(const uint s, const uint e, const uint v) const;
public:
	Multimap();
	Multimap(uint x,uint y);
	~Multimap();
	void resize(uint x, uint y);
	uint	getXY(uint x, uint y) const;
	void	setXY(uint x, uint y, uint v);
	uint	getMaxX() const;
	uint	getMaxY() const;
	uint	getWidth() const;
	uint	getHeight() const;
	bool	modified() const;
	QImage toHeatmap() const;
	QImage toGrayScale() const;
	void stretch();
};

class Trimap: public Multimap {
private:
	uint _aMarkers[3];
public:
	enum	obu {unknown, object, background};
	Trimap();
	Trimap(int x,int y);
	Trimap(uint x,uint y);
	void	setXY(uint x, uint y,obu v);
	void 	resize(uint x, uint y);
	uint	getCount(obu v) const;
	bool	markSquare(int o, int l, int u, int r);
	bool fromFile(std::string s);
	bool toFile(std::string s);
	obu	getXY(uint x, uint y) const;
};
#endif
